package com.group3.hospital.controller;/*
 *@author 时崎
 * 2021/12/30
 */

import com.group3.hospital.bean.Admin;
import com.group3.hospital.bean.User;
import com.group3.hospital.service.AdminService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class AdminController {

    @Resource
    AdminService adminService;

    @RequestMapping("/Admin")
    public String Admin() {
        return "adminLogin";
    }

    @RequestMapping("/backMainUi")
    public String backMainUi(Long adminTel,String adminName,String adminPassword){

        try {
            Admin admin = adminService.queryAdmin(adminTel,adminName,adminPassword);
            if(admin != null){
                return "redirect:/back/BackstageManagementUi";
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "Admin";
    }

    //查看全部用户信息
    @RequestMapping("/admin/userUi")
    public String userUi(Model model){
        try {
            List<User> users = adminService.queryAllUser();
            model.addAttribute("users",users);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
}
